package org.kjk.oracleDB;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class ConnectionFactory {
	public static final int ODBC = 1;
	public static final int ORACLE = 2;

	public ConnectionFactory() {

	}

	public Connection getConnection(int dbms) {
		Connection conn = null;
		String url = null;
		String id = null;
		String pass = null;

		if (dbms == ODBC) {
			url = "jdbc:odbc:dbdsn";
			id = "hr";
			pass = "hr";
			try {
				Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
				conn = DriverManager.getConnection(url, id, pass);
			} catch (SQLException e) {
				e.printStackTrace();
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
			}
		} else if (dbms == ORACLE) {
			url = "jdbc:oracle:thin:@192.168.0.74:1521:xe";
			id = "hr";
			pass = "hr";
			try {
				Class.forName("oracle.jdbc.driver.OracleDriver");
				conn = DriverManager.getConnection(url, id, pass);
			} catch (SQLException e) {
				e.printStackTrace();
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
			}
		}
		return conn;
	}
}
